package com.t174.car.service.impl;

import com.t174.car.dao.ComponentsDao;
import com.t174.car.dao.PurchaseDao;
import com.t174.car.entity.Components;
import com.t174.car.entity.Purchase;
import com.t174.car.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;


@Service
public class PurchaseServiceImpl implements PurchaseService {
    @Autowired
    PurchaseDao purchaseDao;
    @Autowired
    ComponentsDao componentsDao ;


    @Override
    public int addPurchase(Purchase purchase, BigDecimal money) {
            int flag = purchaseDao.addPur(purchase);
            Components carConfig = new Components();
            carConfig.setId(purchase.getId());
//            carConfig.setPurchaseid(purchase.g);
            carConfig.setCount(purchase.getCount());
            carConfig.setPrice(purchase.getPrice());
        return componentsDao.AddComponents(carConfig);
    }

}